﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="testapply.aspx.cs" Inherits="BugSysSolution.ApplyAndCall.testapply" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        </div>
    </form>
</body>
</html>
<script type="text/javascript">
    var Person = function (name, age) {
        this.name = name;
        this.age = age;
    }
    Person.prototype.say = function () {
        alert(this.name);
    }

    var Student = function (name1, age1) {
        //通过改变函数的作用域，来实现继承
        Person.apply(this, [name1, age1]);

        this.sex = "男";
    }

    Student.prototype.say1 = function () {
        alert(this.name);
    }

    var Iter = function () {

        if (arguments.length != 2) {
            alert("初始化失败!");
            return;
        }
        Person.apply(this, [arguments[0], arguments[1]]);
        this.name1 = arguments[0] + "~~";

    }

    Iter.prototype = new Person();

    //Student继承了Person的原型链(包含原型链上面的属性和方法),此时还没有继承Person构造函数里面的属性和方法
    Student.prototype = Person.prototype;

    var p1 = new Person("xxx", "11");
    var s1 = new Student("sss", "22");
    var i1 = new Iter("aaa", "bbb");

    //alert(s1.name);
    //p1.say();
    alert(i1.name + "---" + i1.name1);
    i1.say();
</script>
